﻿using System;
using System.Xml.Serialization;

namespace NapazEngine.Utilities.Data
{
    /// <summary>
    /// This provides a base setting class to hold variables and descriptions
    /// </summary>
    [Serializable]
    public class Setting
    {
        [XmlElement("Name")]
        public string Name { get; set; }
        [XmlElement("Value")]
        public object Value { get; set; }
        [XmlElement("Description")]
        public string Description { get; set; }

        public Setting(string Name, object Value, string Description)
        {
            this.Name = Name;
            this.Value = Value;
            this.Description = Description;
        }

        /// <summary>
        /// Sets the value of the setting
        /// </summary>
        /// <param name="obj"></param>
        public void SetValue(object obj)
        {
            Value = obj;
        }

        /// <summary>
        /// Determines whether two <see cref="Setting"/>s are equal
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            Setting other = obj as Setting;
            return Name.Equals(other.Name) && Value.Equals(other.Value) && Description.Equals(other.Description);
        }

        /// <summary>
        /// Prints out the setting in a string
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return Name + ": " + Value.ToString() + " (" + Description + ")";
        }

        /// <summary>
        /// Not Implemented
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
